package ar.edu.itba.it.cg.grupo01.api;

import java.util.Set;

import javax.vecmath.Point3f;

import ar.edu.itba.it.cg.grupo01.api.shape.Shape;
import ar.edu.itba.it.cg.grupo01.impl.IntersectionFactory;
import ar.edu.itba.it.cg.grupo01.impl.RayTraceInformation;

public interface Intersection<T> {

	/**
	 * Returns the points where the objects intersect. If
	 * {@link #getIntersections()} returns {@code false} then this method
	 * returns an empty {@link Set}
	 * 
	 * @return
	 */
	Set<Point3f> getIntersections();

	/**
	 * Returns the intersection object
	 */
	T getObject();
	
	/**
	 * Returns if this intersection has any results
	 * 
	 * @return true if there are any intersections, false otherwise
	 */
	boolean intersects();

	/**
	 * Returns the minimum distance to this point
	 * @param point
	 * @return minimum distance
	 */
	float distance(Point3f point);

	Point3f closestTo(Point3f origin);

	Intersection<? extends T> getClosestIntersectionTo(Point3f point);

	Intersection.Type getType();

	void setType(Intersection.Type type);

	void getDetails(Shape shape, RayTraceInformation info, float delta, Details details);

	public IntersectionFactory FACTORY = new IntersectionFactory();
	

	public enum Type{
		IN(-1), NO(0), OUT(1);
		
		private int value;

		private Type(int value) {
			this.value = value;
		}
		
		public int value() {
			return value;
		}
	}
	
	public static class Details {
		public float refractionK;
		public float reflectionK;
		public boolean skipRefract;
		public Ray refractedRay;
	}

}
